import socket

# with 是python的语法糖
# IPV4，tcp协议
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.bind(("0.0.0.0", 1234))
    s.listen()
    # s用于监听
    # c 是一个socket，用于玉客户端通信 ，addr是接受的ip地址
    c, addr = s.accept();
    with c:
        print(addr, "connected...")
        while True:
            # 1024个字节
            data = c.recv(1024)
            if not data:
                break;
            c.sendall(data)
